Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for NullReferenceException in lazy bidirectional many-to-one properties #52

Closed
wants to merge 3 commits into from

Conversation

DavidUv
Copy link

@DavidUv DavidUv commented Jun 24, 2024

Having a many-to-one bidirectional mapping with lazy properties will result in a NullReferenceException in AuditEventListener. This change to the AuditEventListener will fix this. There is also an accompanying unit test for this.

The underlying problem that triggered the NullReferenceException was due to the fact that the entity name could not be resolved since it was not of the expected type. The type in the case of a lazy property is a <entity name>ProxyForFieldInterceptor and not the actual type of the entity. Using the NHibernate utility method BestGuessEntityName will resolve to the actual entity name thus satisfying the mapping in Envers.

As I am not familiar to the Envers code base I tried to keep the AuditEventListener changes minimal not to disturb the functionality. All tests passes and this fixes the problem but I'm not totally sure how the mapping actually works and the value argument is still of the ProxyForFieldInterceptor type. Could this be a problem?

@RogerKratz
Copy link
Collaborator

RogerKratz commented Jun 24, 2024

@dennis-gr @maca88 First PR since #50 was merged. do you see any obvious reason why generateasynccode.yml failed here? Seems like a path is wrong.

@RogerKratz RogerKratz closed this Jun 24, 2024
@RogerKratz RogerKratz reopened this Jun 24, 2024
@dennis-gr
Copy link
Contributor

@dennis-gr @maca88 First PR since #50 was merged. do you see any obvious reason why generateasynccode.yml failed here? Seems like a path is wrong.

Yeah, the paths in AsyncGenerator.yml contain a backslash instead of a slash. Should I create a PR for this or can you edit the file?

@RogerKratz
Copy link
Collaborator

thanks for you reply @dennis-gr. updated here 01dd4478e358c72b7f550c8f3df5ca7be39205e5

@DavidUv - can you integrate this PR with latest master and give it a new shot, please?

@DavidUv
Copy link
Author

DavidUv commented Jun 25, 2024

It seems to pass now but I accidentally created a merge instead of a rebase. Should I close this PR and create a new one based on the latest master?

@RogerKratz
Copy link
Collaborator

yeah, do that if you want to. and if you do, please avoid the added/removed spaces changes made in AuditEventListener. Hard to see the actual change. thanks

@DavidUv DavidUv closed this Jun 25, 2024
@DavidUv DavidUv deleted the many-to-one-bidirectional branch June 25, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants